package znet

import (
	"log"
	"net/http"
	// "net/url"
)

// NewClient 创建http客户端
func NewClient() *http.Client {
	// httpTransport := &http.Transport{
	// 	Proxy: func(r *http.Request) (*url.URL, error) { return url.Parse("http://127.0.0.1:8888") }, //连接到fiddler
	// }
	// return &http.Client{Transport: httpTransport}
	return &http.Client{}
}

// Get just reques GET
func Get(httpClient *http.Client, url string) bool {
	res, err := httpClient.Get(url)
	if err != nil {
		log.Println("GET", url, err)
		if res != nil && res.Body != nil {
			res.Body.Close()
		}
		return false
	}
	if res != nil && res.Body != nil {
		res.Body.Close()
	}
	return true
}
